<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>登录页</h1>
    <form action="#">
        <input type="text" class="username">
        <input type="password" class="password">
        <button>登录</button>
    </form>

    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

    <script>
        // axios.get('/api/users/login',{
        //     params:{
        //         name:'fuxiang',
        //         age:18
        //     }
        // })


        // axios.post('/api/users/login',{username:'yuhe',password:'123321'});
            
    
        // // 获取元素  

        const form = document.querySelector('form');
        const username = document.querySelector('.username');
        const password = document.querySelector('.password');

        form.addEventListener('submit',async e=>{
            e.preventDefault();
            const info = {
                username:username.value,
                password:password.value,

            }

            const res = await axios.post('/api/users/login',info);
            console.log(res.data);
        })



        // const arr = [1,2,3,4,5,6,7];

        // console.log(arr.find(item=>item==8));
    </script>
</body>
</html>